#include <common.h>

extern uint64_t inst_cnt;
FILE* log_fp = NULL;

void log_init(const char* log_file){
	printf(ANSI_FMT("\nlog file initializing:",ANSI_FG_BLUE) "%s\n", ANSI_FMT("START", ANSI_FG_GREEN));
	printf("%s:%s\n",ANSI_FMT("WRITING",ANSI_FG_GREEN),log_file?log_file:"stdout");
	log_fp = stdout;
	if (log_file != NULL) {
		FILE *fp = fopen(log_file, "w");
		Assert(fp, "<FILE> Can not open '%s'", log_file);
		log_fp = fp;
	}
	printf(ANSI_FMT("log file initializing:",ANSI_FG_BLUE) "%s\n\n", ANSI_FMT("FINISH", ANSI_FG_GREEN));
}

bool log_enable() {
  return (inst_cnt >= CONFIG_LOG_START) && (inst_cnt <= CONFIG_LOG_END);
}

